<?php

foreach($this->vote_info as $thread_id=>$thread){
    $voteImgArr = array();
    if(count($thread) >= 1){
        
        foreach($thread as $phase_id=>$phase){
            $now = time();
            if($phase->vote_start_time <= $now && $phase->vote_end_time >= $now){
                $voteImgArr = $this->imgList[$phase->thid][$phase->pid];
                break;
            }
        }
        
    }
    if(empty($voteImgArr)) $voteImgArr = $this->imgList[$phase->thid][$phase->pid];
    $photo_block_id = $thread_id."_".$phase_id;
    $photo_block_title = $phase->thread_name.($phase->phase_name != ""?" - ".$phase->phase_name:"");

    if($phase->votephoto_category > 0){
?>

<div class="clear-both"></div>
<div style="float:left; width:410px;">
    <div class="photo-group photo-event">
    <table border="0px" width="100%">
        
        <?php
        if(is_array($voteImgArr) && count($voteImgArr) > 0){
        $i=0;

        foreach($voteImgArr as $imgObj){
            if($i++ %3 ==0) echo "\n    <tr>\n";
        ?>
            <td valign="top"><a href="http://photo.tamtay.vn/photo/view/<?php echo $imgObj->aid;?>" target="_blank" style="text-align:center">
                <img src="<?php echo EVENT_IMG_SERVER."/".$imgObj->thumbnail;?>" width="120px" style="display:block; height:auto; margin-bottom:4px; width:120px;"/>
                <?php echo $imgObj->album_name;?>
            </a></td>
            
        <?php
            if($i %3 ==0) echo "\n    </tr>\n";
        }    // End for loop
        if($i %3 !=0) echo "\n    </tr>\n";
    }    // End if
        ?>
        <tr>
            <td colspan="3"></td>
        </tr>
    </table>
    </div>
</div>

<?php
    }
    else{
?>

<div class="clear-both"></div>
<div style="float:left; width:410px;">
    <div class="photo-group photo-candidate">
    <table border="0px" width="100%">
        
        <?php
        if(is_array($voteImgArr) && count($voteImgArr) > 0){
        $i=0;

        foreach($voteImgArr as $imgObj){
            if($i++ %3 ==0) echo "\n    <tr>\n";
        ?>
            <td valign="top"><a href="http://photo.tamtay.vn/photo/view/<?php echo $imgObj->aid;?>" target="_blank" style="text-align:center">
                <img src="<?php echo EVENT_IMG_SERVER."/".$imgObj->thumbnail;?>" width="120px" style="display:block; height:auto; margin-bottom:4px; width:120px;"/>
                <?php echo $imgObj->album_name;?>
            </a></td>
            
        <?php
            if($i %3 ==0) echo "\n    </tr>\n";
        }    // End for loop
        if($i %3 !=0) echo "\n    </tr>\n";
    }    // End if
        ?>
        <tr>
            <td colspan="3"></td>
        </tr>
    </table>
    </div>
</div>
<div class="clear"></div>

<?php
    }
}
?>